package org.oxenframework.mybatis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.alibaba.druid.pool.DruidDataSource;

/**
 * Mybatis配置 
 * @date 2017-05-21 11:18
 * @author 陈智帅
 */
@Configuration
@EnableTransactionManagement
@EnableConfigurationProperties({ DruidProperties.class })
public class MyBatisAutoConfiguration {

    @Autowired
    DruidProperties druidProperties;
  
    /**
     * 数据源
     */
    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        druidProperties.config(dataSource);
        return dataSource;
    }
}
